using DG.Tweening;
using UnityEngine;

public class C_敌人AI_幽魂_金池 : C_敌人AI_幽魂
{
	public AudioSource _AudioS_金池长老入场;

	private bool _已经飞升;

	private bool _音效已经销毁;

	public override void F_添加状态()
	{
		base.F_添加状态();
		_FSM.states.Add(StateType_Enemy_幽魂.飞升, new EnemyState_金池_飞升().Init(this));
		_AudioS_金池长老入场 = MonoSingleton<AudioManager>.Instance.F_GO_Play_SFX(_AudioC_金池长老入场);
		MonoSingleton<GameManager>.Instance._Pub_PC._On_Die += F_销毁音效;
	}

	private void F_销毁音效()
	{
		if (!_音效已经销毁 && !(_AudioS_金池长老入场 == null))
		{
			_音效已经销毁 = true;
			_AudioS_金池长老入场.DOFade(0f, 3f).SetEase(Ease.Linear).OnComplete(delegate
			{
				Object.Destroy(_AudioS_金池长老入场.gameObject);
			});
		}
	}

	protected override void OnDestroy()
	{
		MonoSingleton<GameManager>.Instance._Pub_PC._On_Die -= F_销毁音效;
		F_销毁音效();
		base.OnDestroy();
	}

	public override void F_定身(float 时间)
	{
		if (!_Is飞升)
		{
			base.F_定身(时间);
		}
	}

	public override void BeAttack(float atk_生命, float atk_僵直, float atk_击退力度, Vector2 atk_Pos, bool atk_Is远程 = false)
	{
		if (!_Is虚幻 && !_Is死亡 && !_Is飞升)
		{
			Debug.LogError(atk_生命);
			if (!_已经飞升 && _Data._CurrHP - atk_生命 <= _Data._MaxHP / 2f)
			{
				_Data._CurrHP -= atk_生命;
				_已经飞升 = true;
				base._UI_BossHP.F_SetVal(_Data._CurrHP, _Data._MaxHP);
				ChangeState(StateType_Enemy_幽魂.飞升);
			}
			else
			{
				base.BeAttack(atk_生命, atk_僵直, atk_击退力度, atk_Pos, atk_Is远程);
			}
		}
	}

	public void F_接触僵尸_回复生命()
	{
		_Data._CurrHP += _Data._MaxHP * 0.075f;
		base._UI_BossHP.F_SetVal(_Data._CurrHP, _Data._MaxHP);
	}
}
